package com.sxz.sbs.module.sms.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.sms.view.SendSmsView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 发送短信P
 */

public class SendSmsPresenter extends RxPresenter<SendSmsView>{
    /**
     * 发送短信
     * @param map
     */
    public void sendSms (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().sendSms(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onSendSmsSuccess(data);
                    }
                })
        );
    }
}
